<template>
  <div class="app-container">
    <!-- <page-search ref="searchRef" :search-config="searchConfig" @query-click="handleQueryClick"
      @reset-click="resetClick">    </page-search> -->
    <PageContent ref="contentRef" :gridOptions="gridOptions" :content-config="contentConfig" @addClick="addFn" @edit-click="handleEditClick"
      @export-click="handleExportClick" @toolbarClick="handleToolbarClick" >
    </PageContent>

    <!-- 新增 -->
    <page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick"> </page-modal>

    <!-- 编辑 -->
    <page-modal ref="editModalRef" :modal-config="editModalConfig" @submit-click="handleSubmitClick"> </page-modal>
  </div>
</template>

<script setup>
import contentConfig from "./config/content";
import addModalConfig from "./config/add";
import editModalConfig from "./config/edit";
import usePage from "@/hooks/usePage";
import { tableHeightAutoAdjust } from '@/utils/common'
import { onMounted } from "vue";
defineOptions({
  name: "operationsCodes",
  inheritAttrs: false,
});

const gridOptions = reactive({})

const { searchRef, contentRef, addModalRef, editModalRef,
  handleQueryClick, handleResetClick, handleAddClick,
  handleSubmitClick, handleExportClick, } = usePage();

const searchParam = ref({})
const setSearchParam = () => {
  searchRef.value.setParams(searchParam.value)
}
const resetClick = () => {
  for (let i in searchParam.value) {
    searchParam.value[i] = ''
  }
  handleResetClick()
}
const handleEditClick = (row) => {
  editModalRef.value?.setModalVisible(row);
}

const addFn = () => {
  handleAddClick()
}
onMounted(() => {
  // 确保在组件挂载后立即设置高度
  tableHeightAutoAdjust(gridOptions);
});
</script>

<style></style>
